Declaration of a method
Syntax |
---|
|
Meaning | |||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
declaration of one or more →methods (a feature of the →object-oriented programming), Observe:
The data type
|
Good to know |
---|
A method behaves as a →function does. |
You are able to use the following language elements for ST within a method:
Blanks, tabs or new lines in ST
Call of function block instance in ST
Declaration of external variables in ST
Declaration of in-out variables in ST
Declaration of input variables in ST
Declaration of internal variables in ST
Declaration of output variables in ST
The usage of these language elements makes it possible to use other elements (e.g. declaration of STRING
variables within the section VAR ... END_VAR
) as well. Such elements are not listed here.
Example 1: Function block with 2 methods for counting up |
---|
|
Example 2: A simple example with methods |
---|
|
Examples 3: Methods are overwritten. |
---|
|
Example 4: Abstract function block and abstract method |
---|
|
Example 5: Function block and method with "FINAL" |
---|
|
Example 6: Methods with different visibility |
---|
|
More examples for methods are specified under "Examples on using interfaces and variables based on these interfaces (incl. assignments)" and "Declaration of a function block in ST".